using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MagicGraph : OBJBase
{
    MagicDot magicDotObject;//阵眼对象
    //存放线段的列表 阵形占据的地图点坐标
    List<MagicLine> magiclines;//地图线段列表
    List<Vector3> peakList;
    List<float[]> points; //拓展图形的所有地板点
    List<float[]> obstaclePoints; //内部点
    bool isLineDraw = false;
    int magicGraphNumber;
    public List<MagicLine> Magiclines { get => magiclines; set => magiclines = value; }
    public List<Vector3> PeakList { get => peakList; set => peakList = value; }
    public List<float[]> ObstaclePoints { get => obstaclePoints; set => obstaclePoints = value; }
    public int MagicGraphNumber { get => magicGraphNumber; set => magicGraphNumber = value; }
    public MagicDot MagicDotObject { get => magicDotObject; set => magicDotObject = value; }


    public MagicGraph()
    {

    }
    public MagicGraph(List<MagicLine> lineList, List<Vector3> peekList, string name)
    {
        magiclines = new List<MagicLine>();
        peakList = new List<Vector3>();
        points = new List<float[]>();
        ObstaclePoints = new List<float[]>();
        Magiclines.AddRange(lineList);
        PeakList.AddRange(peekList);
        CreatDot();
    }
    /// <summary>
    /// 法阵线经过的路径
    /// </summary>
    public void CreatMagicGraphLinePassGrid()
    {
        if (isLineDraw == false)
        {
            for (int i = 0; i < magiclines.Count; i++)
            {
                magiclines[i].ComfirmPassGrid(MagicGraphNumber, i);
            }
            isLineDraw = true;
        }
    }
    void CreatDot()
    {
        MagicDotObject = new MagicDot(AreaController.GetInstance().CreatCenterDot(peakList), magicGraphNumber);
    }

    public void Recycle()
    {
        for (int i = 0; i < Magiclines.Count; i++)
        {
            Magiclines[i].Recycle();

        }
        MagicDotObject.Recycle();
    }
}

